<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
	xmlns:xs="http://www.w3.org/2001/XMLSchema"
	exclude-result-prefixes="xs"
	version="1.0">
	
	<xsl:output method="html"/>
	
	<xsl:template name="emitExtension">
		<xsl:param name="depth" />		
		<xsl:variable name="id" select="@id"/>
		<li id="extension_{$id}">
			<div class="extName"><a href="#" onclick="_ExtDetail({$id})"><xsl:if test="$depth &lt; 2"><xsl:value-of select="name"/></xsl:if> v<xsl:value-of select="version"/>
			</a><xsl:if test="enabled = 'false'">
				<span class="disabled">disabled</span>					
			</xsl:if><xsl:if test="required = 'true'">
				<span class="required">required</span>					
			</xsl:if>
				<div class="extAuthor"><xsl:value-of select="author"/><br />
					<xsl:value-of select="dateInstalled"/></div>
			</div>
			<div class="extDesc"><xsl:value-of select="description"/></div>
			<xsl:variable name="nextDepth" select="$depth + 1"/>
			<xsl:if test="count(//extension[parentID=$id]) &gt; 0">
				<ul class="extList">
					<xsl:for-each select="//extension[parentID=$id]">
						<xsl:sort data-type="number" select="version" order="ascending"/>
						<xsl:call-template name="emitExtension">
							<xsl:with-param name="depth" select="$nextDepth"/>
						</xsl:call-template>
					</xsl:for-each>
				</ul>
			</xsl:if>
		</li>
	</xsl:template>
	
	<xsl:template match="response">
		<ul class="extList">
			<xsl:for-each select="//extension[parentID='0']">
				<xsl:sort data-type="text" select="name" order="ascending"/>
				<xsl:call-template name="emitExtension">
					<xsl:with-param name="depth" select="'1'"/>
				</xsl:call-template>
			</xsl:for-each>
		</ul>
	</xsl:template>
</xsl:stylesheet>